/**
 * 
 */
package com.jrh.dal;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.jrh.domain.common.Page;
import com.jrh.domain.entity.UserScheme;

/**
 * 类UserSchemeDao.java的实现描述：用户方案管理持久层
 * 
 * @author IBM 2012-7-18 下午8:29:11
 */
public class UserSchemeDao extends BaseDao<UserScheme> {

	{
		namespace = "jrh.single.userscheme";
	}

	@SuppressWarnings("unchecked")
	public Page<UserScheme> listByCondition(UserScheme userscheme,
			Integer start, Integer pageSize) {
		Map<String, Object> map = this.getPageMap(start, pageSize);
		map.put("userid", userscheme.getUserid());
		map.put("showroomid", userscheme.getShowroomid());
		map.put("ispublic", userscheme.getIspublic());
		map.put("name", userscheme.getName());
		map.put("designer", userscheme.getDesigner());
		Integer count = (Integer) sqlMapClientTemplate.queryForObject(namespace
				+ "." + "allcount", map);
		if (start >= count & start >= pageSize) {
			start = start - pageSize;
			map = this.getPageMap(start, pageSize);
		}
		List<UserScheme> list = (List<UserScheme>) sqlMapClientTemplate
				.queryForList(namespace + "." + "findAllUserScheme", map);
		return new Page<UserScheme>(list, start, pageSize, count);
	}
	
}
